//! 集群模块错误定义

use thiserror::Error;

#[derive(Error, Debug)]
pub enum ClusterError {
    #[error("Node not found: {0}")]
    NodeNotFound(String),
    
    #[error("Invalid node address: {0}")]
    InvalidAddress(String),
    
    #[error("Network error: {0}")]
    NetworkError(#[from] nacos_network::error::NetworkError),
    
    #[error("Storage error: {0}")]
    StorageError(#[from] nacos_storage::error::StorageError),
    
    #[error("Serialization error: {0}")]
    SerializationError(#[from] serde_json::Error),
    
    #[error("Cluster not initialized")]
    NotInitialized,
    
    #[error("Invalid cluster state: {0}")]
    InvalidState(String),
    
    #[error("Leader election failed: {0}")]
    ElectionFailed(String),
    
    #[error("Configuration error: {0}")]
    ConfigError(String),
    
    #[error("Timeout: {0}")]
    Timeout(String),
    
    #[error("Consensus error: {0}")]
    ConsensusError(String),
}
